package com.dt.platform.generator.module.hr;


import com.dt.platform.constants.db.HrTables;
import com.dt.platform.constants.enums.common.StatusEnableEnum;
import com.dt.platform.constants.enums.common.YesNoEnum;
import com.dt.platform.constants.enums.hr.PaperQuestionTypeEnum;
import com.dt.platform.domain.hr.*;
import com.dt.platform.domain.hr.meta.*;
import com.dt.platform.generator.config.Config;
import com.dt.platform.hr.page.PaperQuestionRelPageController;
import com.dt.platform.proxy.hr.LearnPaperServiceProxy;
import com.dt.platform.proxy.hr.LearnServiceProxy;
import com.dt.platform.proxy.hr.PaperQuestionRelServiceProxy;
import com.github.foxnic.generator.builder.view.config.DatePickerType;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.system.DictItem;
import org.github.foxnic.web.domain.system.meta.DictItemMeta;
import org.github.foxnic.web.proxy.system.DictItemServiceProxy;


public class APaperQuestionRelGtr extends BaseCodeGenerator {
    public APaperQuestionRelGtr() {
        super(HrTables.HR_PAPER_QUESTION_REL.$TABLE,"811268060357853184");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.getPoClassFile().addSimpleProperty(DictItem.class,"levelDict","levelDict","levelDict");



        cfg.getPoClassFile().addSimpleProperty(LearnPaper.class,"learnPaper","learnPaper","learnPaper");
        cfg.getPoClassFile().addSimpleProperty(Paper.class,"Paper","Paper","Paper");
        cfg.getPoClassFile().addSimpleProperty(PaperQuestion.class,"paperQuestion","paperQuestion","paperQuestion");
        cfg.getPoClassFile().addSimpleProperty(String.class,"selectedCode","selectedCode","selectedCode");

        cfg.getPoClassFile().addListProperty(PaperQuestionItem.class,"paperQuestionItemList","paperQuestionItemList","paperQuestionItemList");

        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_NAME).form().search().fuzzySearch();
        cfg.view().search().inputLayout(
                new Object[]{
                        HrTables.HR_PAPER_QUESTION_REL.LEARN_PAPER_ID,
                        HrTables.HR_PAPER_QUESTION_REL.QUESTION_TYPE,
                        HrTables.HR_PAPER_QUESTION_REL.QUESTION_NAME,

                }
        );



        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_LEVEL).form().selectBox()
                .queryApi(DictItemServiceProxy.QUERY_PAGED_LIST+"?dictCode=hr_question_level")
                .paging(true).filter(true).toolbar(false)
                .valueField(DictItemMeta.CODE).
                textField(DictItemMeta.LABEL).
                fillWith(PaperQuestionRelMeta.LEVEL_DICT).muliti(false).defaultIndex(0);


        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.LEARN_PAPER_ID).form().selectBox()
                .queryApi(LearnPaperServiceProxy.QUERY_PAGED_LIST)
                .paging(true).filter(true).toolbar(false)
                .valueField(LearnPaperMeta.ID).
                textField(LearnPaperMeta.NAME).
                fillWith(PaperQuestionRelMeta.LEARN_PAPER).muliti(false).defaultIndex(0);


        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_ID).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.ID).basic().hidden(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.IS_ANSWER).form().radioBox().enumType(YesNoEnum.class).defaultIndex(0);

        cfg.getPoClassFile().addListProperty(PaperQuestionAnswer.class,"paperQuestionAnswerList","paperQuestionAnswerList","paperQuestionAnswerList");

        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_TYPE).form()
                .radioBox().enumType(PaperQuestionTypeEnum.class).defaultIndex(0);




        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.ITEM_ANSWER_TEXT_RIGHT).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.IS_ANSWER).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.PAPER_ID).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.UPDATE_BY).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.UPDATE_BY).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.UPDATE_TIME).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.CREATE_BY).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.CREATE_TIME).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.ITEM_ANSWER_TEXT).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.ITEM_TEXT).form().table().disable(true);

        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_IMAGE_ID).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_FILE_ID).form().table().disable(true);

        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.SORT).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_LEVEL).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_ANALYSIS).form().table().disable(true);
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_NUMBER).form().table().disable(true);

        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);


        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_IMAGE_ID).form().upload().acceptSingleImage().buttonLabel("上传图片");
        cfg.view().field(HrTables.HR_PAPER_QUESTION_REL.QUESTION_FILE_ID).form().upload().acceptSingleFile().buttonLabel("上传附件");


        cfg.view().search().rowsDisplay(1);
        cfg.view().formWindow().width("80%");;
        cfg.view().formWindow().bottomSpace(150);


        cfg.view().form().addGroup(null,
                new Object[] {
                        HrTables.HR_PAPER_QUESTION_REL.SCORE,
                        HrTables.HR_PAPER_QUESTION_REL.SORT,
                }
        );


        cfg.view().list().addToolButton("选择题目","selectQuestion","selectQuestion");

        cfg.view().list().addJsVariable("PAGE_TYPE","[[${pageType}]]","pageType");
        cfg.view().list().addJsVariable("PAPER_ID","[[${paperId}]]","paperId");

        cfg.view().list().addJsVariable("SELECTED_CODE","[[${selectedCode}]]","selectedCode");

        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setBpmEventAdaptor(WriteMode.COVER_EXISTS_FILE)
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE) //列表HTML页
                .setExtendJsFile(WriteMode.IGNORE);
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        APaperQuestionRelGtr g=new APaperQuestionRelGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
       // System.out.println("############"+g.getTablePrefix());
       // g.removeByBatchId("801716675761143808");
      //  //生成菜单
       //g.generateMenu(PaperQuestionRelServiceProxy.class, PaperQuestionRelPageController.class);
    }
}
